
-- 第三级提示：核心属性tip

local ClassRef = app.mvc.createPanelClass(...)

local newFromBtnView = import(".floatSubmodule.newFromBtnView") -- 操作按钮
local CorePropUIHelp = require("app.coreProp.CorePropUIHelp")
local IconRender = require("app.widget.renders.IconRender")
local Item = require("app.public.dao.Item")
--data =
function ClassRef.create()
    local sprite = ClassRef.extend(cc.CSLoader:createNode(Res.CorePropItemTip))
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init(data)
    return sprite
end

function ClassRef:init(data)
    self.super.init(self, data)

    self._fromBtnTips = newFromBtnView.new()
    self._fromBtnTips:setClickCB( handler( self, self._clickCb ) )
    self._ui["Panel/from"]:addChild(self._fromBtnTips)
   
    self._icon = IconRender.create(self._ui["Panel/icon"])
    self._icon:setClickEnable(false)
    local itemTemp = Item.new( Enums.ItemBagType.item )
    itemTemp:read( { tid = Constant.CoreProp_ItemId } )
    self._icon:setData(itemTemp)
    self._iconData = itemTemp
    
    local itemNum = CorePropUIHelp.getCorePropItemNum()
    local itemCost = CorePropUIHelp.getCorePropItemCost(UD.coreProp:getSumPoint())
    self._ui["Panel/num"]:setString(string.format(L("lua_code_text_87"), itemNum, itemCost))

    local _getResource = self._iconData:getResource()
    if _getResource then
        self._fromBtnTips:refreshContent( _getResource )
    else
        self._fromBtnTips:setVisible(false)
    end
    
   
    -- self:refresh()
end

function ClassRef:refresh()
    
end

function ClassRef:_clickCb( op, ... )
    local data = ...
    -- dump( data, " ------------->>>> newFloatTipsView:_clickCb " .. op )
    if "goto_feature" == op then
        UIHandler:handleMessage( { id = tonumber( data.feature ), mode = "open" } )
        self:hide()
        executeFunc(self._onOperate, self)
    end
end

function ClassRef:hide()
    self._fromBtnTips:hide()
    self:setVisible(false)
end

function ClassRef:onOperate(cb)
    -- body
    self._onOperate = cb
end

return ClassRef
